package org.jeecg.modules.front.controller;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.front.model.WorkOrderModel;
import org.jeecg.modules.front.service.HomeWorkOrderService;
import org.jeecg.modules.front.vo.*;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 首页接口
 */
@RestController
@RequestMapping("/homeWorkOrder")
public class HomeWorkOrderController {

    @Resource
    private HomeWorkOrderService service;


    @RequestMapping("/frontLook4")
    public Result<List<TicketPersonVo>> frontLook4(WorkOrderModel workOrderModel){
        if(workOrderModel==null){
            workOrderModel.setWorkType(1);
            workOrderModel.setX("desc");
        }
        List<TicketPersonVo> ticketPersonVos = service.module4(workOrderModel);
        return  Result.OK(ticketPersonVos);
    }

    @RequestMapping("/frontLook1")
    public Result<OrdersVo> frontLook1(){
        OrdersVo vo = service.module1();
        return  Result.OK(vo);
    }


    @RequestMapping("/frontLook2")
    public Result<CompleteVo> frontLook2(){
        CompleteVo vo = service.module2();
        return  Result.OK(vo);
    }

    @RequestMapping("/frontLook3")
    public Result<OrderCompletionRateVo> frontLook3(){
        OrderCompletionRateVo vo = service.module3();
        return  Result.OK(vo);
    }

    @RequestMapping("/frontLook")
    public Result<Map<String,Object>> frontLook(){
        OrdersVo vo1 = service.module1();
        CompleteVo vo2 = service.module2();
        OrderCompletionRateVo vo3 = service.module3();
        Map<String,Object> map=new HashMap<>();
        map.put("module1",vo1);
        map.put("module2",vo2);
        map.put("module3",vo3);
        return  Result.OK(map);
    }

    @RequestMapping("/frontType")
    public Result<List<TypeVo>> frontType(){
        List<TypeVo> list=service.orderType();
        return  Result.OK(list);
    }
}
